home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / Chip_2004-03_cd1.bin / zkuste / defrag / download / oodefrag / O&O Defrag Professional Edition.msi / Data1.cab / oodpe.chm / doctohelp.js < prev    next >
Text File  |  2003-12-15  |  8KB  |  336 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // dhtml functions: require IE4 or later
  4. //
  5. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6.  
  7. var POPUP_COLOR = 0xffffe0;
  8.  
  9. function dhtml_popup(url)
  10. {
  11.     var pop, main, body, x, y;
  12.  
  13.     // no url? then hide the popup
  14.     if (url == null || url.length == 0)
  15.     {
  16.         pop = document.all["popupFrame"];
  17.         if (pop != null)
  18.             pop.style.display = "none";
  19.         return;
  20.     }
  21.  
  22.     // if the popup frame is already open, close it first
  23.     if (dhtml_popup_is_open())
  24.     {
  25.         // the main window is the parent of the popup frame
  26.         main = window.parent;
  27.         body = main.document.body;
  28.         pop = main.document.all["popupFrame"];
  29.  
  30.         // add the popup origin to the event coordinates
  31.         x = pop.offsetLeft + window.event.offsetX;
  32.         y = pop.offsetTop + window.event.offsetY;
  33.  
  34.         // hide the popup frame
  35.         pop.style.display = "none";
  36.     }
  37.     else
  38.     {
  39.         // the main window is the current window
  40.         main = window;
  41.         body = document.body;
  42.         pop = document.all["popupFrame"];
  43.  
  44.         // use the event coordinates for positioning the popup
  45.         x = window.event.x;
  46.         y = window.event.y;
  47.  
  48.         // account for the scrolling text region, if present
  49.         var nstx = document.all["nstext"];
  50.         if (nstx != null)
  51.             y += nstx.scrollTop - nstx.offsetTop;
  52.  
  53.         // get the popup frame, creating it if needed
  54.         if (pop == null)
  55.         {
  56.             var div = document.all["popupDiv"];
  57.             if (div == null)
  58.                 return;
  59.  
  60.             div.innerHTML = "<iframe id=\"popupFrame\" frameborder=\"none\" scrolling=\"none\" style=\"display:none\"></iframe>";
  61.             pop = document.all["popupFrame"];
  62.         }
  63.     }
  64.  
  65.     // get frame style
  66.     var sty = pop.style;
  67.  
  68.     // load url into frame
  69.     pop.src = url;
  70.  
  71.     // initialize frame size/position
  72.     sty.position  = "absolute";
  73.     sty.border    = "1px solid #cccccc";
  74.     sty.posLeft   = x + body.scrollLeft     - 30000;
  75.     sty.posTop    = y + body.scrollTop + 15 - 30000;
  76.     var wid       = body.clientWidth;
  77.     sty.posWidth  = (wid > 500)? wid * 0.6: wid - 20;
  78.     sty.posHeight = 0;
  79.  
  80.     // wait until the document is loaded to finish positioning
  81.     main.setTimeout("dhtml_popup_position()", 100);
  82. }
  83.     
  84. function dhtml_popup_is_open()
  85. {
  86.     return window.location.href != window.parent.location.href;
  87. }
  88.  
  89. function dhtml_popup_position()
  90. {
  91.     // get frame
  92.     var pop = document.all["popupFrame"];
  93.     var frm = document.frames["popupFrame"];
  94.     var sty = pop.style;
  95.  
  96.     // get containing element (scrolling text region or document body)
  97.     var body = document.all["nstext"];
  98.     if (body == null)
  99.         body = document.body;
  100.  
  101.     // hide navigation/nonscrolling elements, if present
  102.     dhtml_popup_elements(frm.self.document);
  103.  
  104.     // get content size
  105.     sty.display = "block";
  106.     frm.scrollTo(0,1000);
  107.     sty.posHeight = frm.self.document.body.scrollHeight + 20;
  108.  
  109.     // make content visible
  110.     sty.posLeft  += 30000;
  111.     sty.posTop   += 30000;
  112.  
  113.     // adjust x position
  114.     if (sty.posLeft + sty.posWidth + 10 - body.scrollLeft > body.clientWidth)
  115.         sty.posLeft = body.clientWidth  - sty.posWidth - 10 + body.scrollLeft;
  116.  
  117.     // if the frame fits below the link, we're done
  118.     if (sty.posTop + sty.posHeight - body.scrollTop < body.clientHeight)
  119.         return;
  120.  
  121.     // calculate how much room we have above and below the link
  122.     var space_above = sty.posTop - body.scrollTop;
  123.     var space_below = body.clientHeight - space_above;
  124.     space_above -= 35;
  125.     space_below -= 20;
  126.     if (space_above < 50) space_above = 50;
  127.     if (space_below < 50) space_below = 50;
  128.  
  129.     // if the frame fits above or we have a lot more room there, move it up and be done
  130.     if (sty.posHeight < space_above || space_above > 2 * space_below)
  131.     {
  132.         if (sty.posHeight > space_above)
  133.             sty.posHeight = space_above;
  134.         sty.posTop = sty.posTop - sty.posHeight - 30;
  135.         return;
  136.     }
  137.  
  138.     // adjust frame height to fit below the link
  139.     sty.posHeight = space_below;
  140. }
  141.  
  142. function dhtml_popup_elements(doc)
  143. {
  144.     // hide navigation bar, if present
  145.     var nav = doc.all["ienav"];
  146.     if (nav != null)
  147.         nav.style.display = "none";
  148.  
  149.     // set popup color and remove background image
  150.     doc.body.style.backgroundColor = POPUP_COLOR;
  151.     doc.body.style.backgroundImage = "none";
  152.  
  153.     // reset popup color of title row, if present
  154.     var trow = doc.all["TitleRow"];
  155.     if (trow != null)
  156.         trow.style.backgroundColor = POPUP_COLOR;
  157.  
  158.     // reset border/color of nonscrolling banner, if present
  159.     var nsb = doc.all["nsbanner"];
  160.     if (nsb != null)
  161.     {
  162.         nsb.style.borderBottom = "0px";
  163.         nsb.style.backgroundColor = POPUP_COLOR;
  164.     }
  165.  
  166.     // reset background image/color of scrolling text region, if present
  167.     var nstx = doc.all["nstext"];
  168.     if (nstx != null)
  169.     {
  170.         nstx.style.backgroundColor = POPUP_COLOR;
  171.         nstx.style.backgroundImage = "none";
  172.     }
  173. }
  174.  
  175. function dhtml_nonscrolling_resize()
  176. {
  177.     if (document.body.clientWidth == 0)
  178.         return;
  179.  
  180.     var oBanner= document.all.item("nsbanner");
  181.     var oText= document.all.item("nstext");
  182.  
  183.     if (oText == null)
  184.         return;
  185.  
  186.     var oTitleRow = document.all.item("TitleRow");
  187.  
  188.     if (oTitleRow != null)
  189.         oTitleRow.style.padding = "0px 10px 0px 22px;";
  190.  
  191.     if (oBanner != null)
  192.     {
  193.         document.body.scroll = "no"
  194.         oText.style.overflow = "auto";
  195.          oBanner.style.width = document.body.offsetWidth - 4;
  196.         oText.style.paddingRight = "20px"; // Width issue code
  197.         oText.style.width = document.body.offsetWidth - 4;
  198.         oText.style.top = 0;  
  199.  
  200.         if (document.body.offsetHeight > oBanner.offsetHeight + 4)
  201.             oText.style.height = document.body.offsetHeight - oBanner.offsetHeight - 4;
  202.         else
  203.             oText.style.height = 0;
  204.     }    
  205.  
  206. //    try{nstext.setActive();} //allows scrolling from keyboard as soon as page is loaded. Only works in IE 5.5 and above.
  207. //    catch(e){}
  208.  
  209.     window.onresize = d2hnsresize;
  210.  
  211. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  212. //
  213. // d2h functions: browser-independent
  214. //
  215. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  216.  
  217. function d2hie()
  218. {
  219.     var ie = navigator.userAgent.toLowerCase().indexOf("msie");
  220.     return ie != -1 && parseInt(navigator.appVersion) >= 4;
  221. }
  222.  
  223. function d2hpopup(url)
  224. {
  225.     // use dhtml if we can
  226.     if (d2hie())
  227.     {
  228.         dhtml_popup(url);
  229.         return false;
  230.     }
  231.  
  232.     // use regular popups
  233.     if (url != null && url.length > 0)
  234.     {
  235.         var pop = window.open(url, '_d2hpopup', 'resizable=1,toolbar=0,directories=0,status=0,location=0,menubar=0,height=300,width=400');
  236.         pop.focus();                 // if the popup was already open
  237.         pop.onblur = "self.close()"; // doesn't work, not sure why...
  238.     }
  239.  
  240.     // and ignore the click
  241.     return false;
  242. }
  243.  
  244. function d2hwindow(url, name)
  245. {
  246.     if (name != 'main')
  247.     {
  248.         window.open(url, name, 'scrollbars=1,resizable=1,toolbar=0,directories=0,status=0,location=0,menubar=0,height=300,width=400');
  249.         return false;
  250.     }
  251.     return true;
  252. }
  253.  
  254. function d2hcancel(msg, url, line)
  255. {
  256.     return true;
  257. }
  258.  
  259. function d2hload()
  260. {
  261.     window.focus();
  262.     window.onerror = d2hcancel;
  263.     if (window.name == '_d2hpopup')
  264.     {
  265.         var major = parseInt(navigator.appVersion);
  266.         if (major >= 4)
  267.         {
  268.             var agent = navigator.userAgent.toLowerCase();
  269.             if (agent.indexOf("msie") != -1)
  270.                 document.all.item("ienav").style.display = "none";
  271.             else
  272.                 document.layers['nsnav'].visibility = 'hide';
  273.         }
  274.     }
  275. }
  276.  
  277. function d2hframeload()
  278. {
  279.     // for compatibility with HTML generated by earlier versions
  280. }
  281.  
  282. function d2htocload()
  283. {
  284.     if (d2hie())
  285.     {
  286.         var id, elt;
  287.         var count = document.all.length;
  288.  
  289.         for (i = 0; i < count; i++)
  290.         {
  291.             elt = document.all.item(i);
  292.  
  293.             if (elt.id.substring(0, 1) == "c")
  294.                 elt.style.display = "none";
  295.  
  296.             else if (elt.id.substring(0, 2) == "mi")
  297.                 elt.src = "closed.gif";
  298.         }
  299.     }
  300. }
  301.  
  302. function d2hclick()
  303. {
  304.     if (d2hie())
  305.     {
  306.         var id = window.event.srcElement.id;
  307.  
  308.         if (id.substring(0, 1) != "m")
  309.             return;
  310.  
  311.         var sub = id.substring(2);
  312.         var elt = document.all.item("c" + sub);
  313.         var img = document.all.item("mi" + sub);
  314.  
  315.         if (elt.style.display == "none")
  316.         {
  317.             elt.style.display = "";
  318.             img.src = "open.gif";
  319.         }
  320.  
  321.         else
  322.         {
  323.             elt.style.display = "none";
  324.             img.src = "closed.gif";
  325.         }
  326.     }
  327. }
  328.  
  329. function d2hnsresize()
  330. {
  331.     if (d2hie())
  332.         dhtml_nonscrolling_resize();
  333.  
  334.